<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
    <title>CProxy后台</title>
    <link href="css/weui.css" rel="stylesheet">
    <link href="css/example.css" rel="stylesheet">
    <script src="js/jquery-2.2.2.min.js"></script>
</head>
<body ontouchstart>
    <div class="container js_container"></div>
</body>
<script type="text/html" id="tpl_home">
    <div class="hd">
        <h1 class="page_title">CProxy后台-奔放网</h1>
        <p class="page_desc" id="nowversion1">当前版本：</p>
    </div>
    <div class="bd spacing">
        <div class="weui_cells_title">流量</div>
        <div class="weui_cells">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>上行流量</p>
                </div>
                <div class="weui_cell_ft" id="upload"></div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>下行流量</p>
                </div>
                <div class="weui_cell_ft" id="download"></div>
            </div>
        </div>
        <div class="weui_cells_title">内存</div>
        <div class="weui_cells">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>内存占用</p>
                </div>
                <div class="weui_cell_ft" id="memory"></div>
            </div>
        </div>
        <a href="javascript:;" class="weui_btn weui_btn_primary" id="clear">清 理 内 存</a>
        <br/>
             
</script>

<script>
    function getMemory(){
        $.ajax({
            type: "GET",
            url: "/?memory",
            async: true,
            success: function(data){
                var array = JSON.parse(data);
                $("#memory").html(array.memory);
            }
        });
    }
    function getQueryFlow(){
        $.ajax({
            type: "GET",
            url: "/?queryFlow",
            async: true,
            success: function(data){
                var array = JSON.parse(data);
                $("#upload").html(array.upload);
                $("#download").html(array.download);
            }
        });
    }
    function clear(){
        $.ajax({
            type: "GET",
            url: "/?clear",
            async: true
        });
    }
    function main(){
        $.ajax({
            type: "GET",
            url: "/?version",
            async: true,
            success: function(data){
                var array = JSON.parse(data);
                version = array.version;
                $("#nowversion1").html("当前版本：v" + version);
            
                getQueryFlow();
                getMemory();
            }
        });
        $("#clear").click(function(){
            clear();
            getQueryFlow();
            getMemory();
        });

        $("#communicate").click(function(){
            $("#dialog").css("display", "block");
        });
        $(".weui_btn_dialog.primary").click(function(){
            $("#dialog").css("display", "none");
        });
    }
    $(function(){
        setTimeout(main, 10);
    });
    
</script>
<script src="js/example.js"></script>
<script src="js/zepto.min.js"></script>
</html>